package message

import (
	"fmt"
	"mass-user/commons/user"
)

const (
	LoginMessageType            = "loginMessage"
	LoginResponseMessageType    = "loginResponseMessage"
	RegisterMessageType         = "registerMessage"
	RegisterResponseMessageType = "registerResponseMessage"
	NotifyUserStatusMesType     = "notifyUserStatusMessage"
)

const (
	UserOnline = "在线"
	UserOffline
)

type Message struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type LoginMessage struct {
	UserId   int64  `json:"userId"`
	Pwd      string `json:"pwd"`
	UserName string `json:"userName"`
}

type LoginResponseMessage struct {
	Code  int    `json:"code"`
	Users []int  `json:"users"`
	Error string `json:"error"`
}
type RegisterMessage struct {
	User user.User `json:"user"`
}

type RegisterResponseMessage struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

func (msg Message) String() string {
	return fmt.Sprintf("{'Type':%v,'Data': %v}", msg.Type, msg.Data)
}

type NotifyUserStatusMes struct {
	UserId int    `json:"userId"`
	Status string `json:"status"`
}
